package com.lemon.smartsafety.ui.adapter.safe.data;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.lemon.smartsafety.entity.safe.company.CompanyInfo;
import com.lemon.smartsafety.listener.RecyclerTClickListener;

import java.util.List;

import kale.adapter.LemonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Cooliean on 16/2/22.
 * 企业信息列表适配
 */
public class SafeDataCompanyInfoAdapter extends LemonRcvAdapter<CompanyInfo> {
    private RecyclerTClickListener<CompanyInfo> mListener;


    private SafeDataCompanyInfoItem mItem = null;

    public SafeDataCompanyInfoAdapter(@Nullable List<CompanyInfo> data, RecyclerTClickListener<CompanyInfo> listener) {
        super(data);
        mListener = listener;
    }

    private SafeDataCompanyInfoAdapter(@Nullable List<CompanyInfo> data) {
        super(data);
    }


    @Override
    public Object getItemType(CompanyInfo data) {
        return -1;
    }


    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        return getListItem();
    }


    private SafeDataCompanyInfoItem getListItem() {
        if (mItem != null) return mItem;
        return new SafeDataCompanyInfoItem(mListener);
    }
}
